﻿// -----------------------------------------------------------------------
// <copyright file="ElementTpe.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace FormCreator.Model
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using WPForms.Common;

    /// <summary>
    /// Model class which represents a form element type.
    /// </summary>
    public class ElementType
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ElementType" /> class.
        /// </summary>
        /// <param name="type">The type.</param>
        public ElementType(Type type)
        {
            this.Type = type;
            var description = type.GetCustomAttributes(typeof(DescriptionAttribute), true).FirstOrDefault(a => a is DescriptionAttribute) as DescriptionAttribute;
            if (description != null)
            {
                this.Description = description.Description;
            }
        }

        /// <summary>
        /// Gets the type.
        /// </summary>
        public Type Type { get; private set; }

        /// <summary>
        /// Gets the name of the type.
        /// </summary>
        public string Name
        {
            get
            {
                return this.Type.Name;
            }
        }

        /// <summary>
        /// Gets the description.
        /// </summary>
        public string Description { get; private set; }
    }
}
